package com.dazhi.boot;

import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.io.support.SpringFactoriesLoader;

import java.util.Iterator;

public class DefaultApplicationContextFactory implements ApplicationContextFactory{
    @Override
    public ConfigurableApplicationContext create() {
        Iterator var4 = SpringFactoriesLoader.loadFactories(ApplicationContextFactory.class, this.getClass().getClassLoader()).iterator();
        ConfigurableApplicationContext result;
        ConfigurableApplicationContext defaultResult = new AnnotationConfigApplicationContext();
        do {
            if (!var4.hasNext()) {
                return defaultResult != null ? defaultResult : null;
            }
            ApplicationContextFactory candidate = (ApplicationContextFactory)var4.next();
            result = candidate.create();
        } while(result == null);
        return result;
    }
}
